<template>
  <!-- 权限按钮组 -->
  <div id="authButtons">
    <el-button type="primary" @click="handleAudit" v-if="authData.id"
      >审批</el-button
    >
    <el-button
      type="success"
      v-if="authData.isAddSign == 1 && authData.auditType == 1"
      @click="handleAddSgin"
      >加签</el-button
    >
    <check-dialog ref="checkDialog" @update="relodPart"></check-dialog>

    <add-sgin-dialog ref="addSginDialog" @update="relodPart"></add-sgin-dialog>
  </div>
</template>
<script>
import checkDialog from '@/components/checkDialog'
import addSginDialog from '@/components/addSign'
export default {
  name: '',
  data () {
    return {
      authData: {}
    }
  },
  props: {
    info: {
      type: Object,
      default: () => { }
    }
  },
  components: {
    checkDialog,
    addSginDialog
  },
  mounted () {
    this.checkUserIsAudit()
  },
  methods: {
    // 检测当前用户是否有审核的权限
    async checkUserIsAudit () {
      let { data } = await this.$API.workflow.checkUserIsAudit.get(this.info)
      this.authData = data
    },
    // 审批
    handleAudit () {
      this.$nextTick(() => {
        this.$refs.checkDialog.open(this.info)
      })
    },
    // 加签
    handleAddSgin () {
      this.$nextTick(() => {
        this.$refs.addSginDialog.open(this.authData)
      })
    },
    relodPart () {
      this.checkUserIsAudit()
      this.$emit('updatePage')
    }
  }
}
</script>
<style lang="scss" scoped>
#authButtons {
  position: fixed;
  top: 20%;
  right: 20px;
  z-index: 999;
}
</style>